--
--      Package File Template
--
--      Purpose: This package defines supplemental types, subtypes, 
--               constants, and functions 
--
--   To use any of the example code shown below, uncomment the lines and modify as necessary
--

library IEEE;
use IEEE.STD_LOGIC_1164.all;

package FAW_TYPES is

-- type <new_type> is
--  record
--    <type_name>        : std_logic_vector( 7 downto 0);
--    <type_name>        : std_logic;
-- end record;
--
-- Declare constants
--
-- constant <constant_name>             : time := <time_unit> ns;
-- constant <constant_name>             : integer := <value;
--
-- Declare functions and procedure
--
-- function <function_name>  (signal <signal_name> : in <type_declaration>) return <type_declaration>;
-- procedure <procedure_name> (<type_declaration> <constant_name>       : in <type_declaration>);
--
        constant W : integer := 640;
        constant H: integer := 480;
        constant P: integer := 4; --deve essere una potenza di due
        constant N: integer :=31; --dimensione della finestra
        constant N_MEZZI: integer :=15;  
        constant DMAX: integer := 4;
        constant DMIN: integer := 0;
        constant N_SP_IN_ROW: integer := W/P;
        constant N_MAX_COLUMNS:integer := (N/P)+1;
        constant N_BIT_BR_CENTRALS: integer :=14; --log2((W-(N-1))(N/2)+N/2+1)
        constant N_BIT_BR_SAMPLED: integer := 8;
        subtype COUNTER_ROWS is integer range 0 to H; --contatore delle righe 
        subtype COUNTER_COLUMNS is integer range 0 to W; --contatore delle colonne
        subtype COUNTER_CENTRALS is integer range 0 to (W-N)*(H-N);
--      constant RSPSR_SR_CELLS: integer := (N/P)+1;
        constant RSPSRC_SR_REGISTERS : integer :=(N/P)+1;
        constant DURATA_S1 : integer := P - (N mod P);
        constant DURATA_S2 : integer := N mod P;
        constant N_DISPARITY : integer:= DMAX-DMIN+1;
        --testing
        constant SR_CELLS: integer :=5;
        
        --tipi per reference
        type RSPSR_SR_DATA_BUS is array (N_SP_IN_ROW-1 downto 0) of std_logic_vector(7 downto 0);
        type RSPSRC_SR_DATA_BUS is array (RSPSRC_SR_REGISTERS-1 downto 0) of RSPSR_SR_DATA_BUS;
        TYPE RSP_BR_ADDRESS_BUS is array (N_SP_IN_ROW-1 downto 0) of std_logic_vector(N_BIT_BR_SAMPLED-1 downto 0); --log2(W/p) downto 0
--      type BR_WEA_BUS is array (N_SP_IN_ROW-1 downto 0) of std_logic_vector(0 downto 0);
--      type BR_ENABLE_BUS is array (N_SP_IN_ROW-1 downto 0) of std_logic;
        
        type SR_DATA_OUT_BUS is array (N_SP_IN_ROW-1 downto 0) of std_logic_vector(7 downto 0);
--      type BR_DATA_OUT_BUS is array (RSPSR_SR_CELLS-1 downto 0) of std_logic_vector(7 downto 0);
        type SR_ENABLE_BUS is array (RSPSRC_SR_REGISTERS-1 downto 0) of std_logic_vector(N_SP_IN_ROW-1 downto 0);
        type SR_ENABLE_ROWS is array (RSPSRC_SR_REGISTERS-1 downto 0) of std_logic;
        
        --tipi per target
        type TCPSR_SR_DATA_BUS is array (N_DISPARITY-1 downto 0) of std_logic_vector(7 downto 0);
        type TSPSR_SR_DATA_BUS is array (W-1 downto 0) of std_logic_vector(7 downto 0);
        type TARGET_SR_ENABLE_BUS is array (RSPSRC_SR_REGISTERS-1 downto 0) of std_logic_vector(W-1 downto 0);
        type TARGET_SR_ENABLE_ROWS is array (RSPSRC_SR_REGISTERS-1 downto 0) of std_logic;
        type TSPSRC_SR_DATA_BUS is array (RSPSRC_SR_REGISTERS-1 downto 0) of TSPSR_SR_DATA_BUS;
end FAW_TYPES;

package body FAW_TYPES is

---- Example 1
--  function <function_name>  (signal <signal_name> : in <type_declaration>  ) return <type_declaration> is
--    variable <variable_name>     : <type_declaration>;
--  begin
--    <variable_name> := <signal_name> xor <signal_name>;
--    return <variable_name>; 
--  end <function_name>;

---- Example 2
--  function <function_name>  (signal <signal_name> : in <type_declaration>;
--                         signal <signal_name>   : in <type_declaration>  ) return <type_declaration> is
--  begin
--    if (<signal_name> = '1') then
--      return <signal_name>;
--    else
--      return 'Z';
--    end if;
--  end <function_name>;

---- Procedure Example
--  procedure <procedure_name>  (<type_declaration> <constant_name>  : in <type_declaration>) is
--    
--  begin
--    
--  end <procedure_name>;
 
end FAW_TYPES;